<template>
    <div>
        <input type="text" @input="addInput($event, 'tom')" />
        <button @click="getInfo">click</button>
    </div>
</template>

<script setup lang="ts">
const addInput = (e: Event, val: string): void => {
    console.log((e.target as HTMLInputElement).value)
    
}   //遇到两个点的通常加类型断言

const getInfo = (e: Event) => {
    console.log((e.target as HTMLButtonElement).innerHTML)
}
</script>

<style scoped></style>